package com.example.demo.security.service.Impl;

import com.example.demo.common.MyBatisUtils;
import com.example.demo.security.dao.AdminUserDao;
import com.example.demo.security.model.AdminUser;
import com.example.demo.security.service.AdminUserService;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AdminUserServiceImpl implements AdminUserService {
    @Resource
    private AdminUserDao adminUserDao;
    @Override
    public AdminUser adminUserName(String userName) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        AdminUserDao adminUserDao =  sqlSession.getMapper(AdminUserDao.class);
        AdminUser adminUser = adminUserDao.selectByUserName(userName);
        sqlSession.close();
        return adminUser;
    }

    @Override
    public boolean login(String username, String password) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        AdminUserDao adminUserDao =  sqlSession.getMapper(AdminUserDao.class);
        boolean adminUser = adminUserDao.selectByPassword(username,password);
        sqlSession.close();
        return adminUser;
    }
}
